package space.jamestang.simpleci.schema

import org.ktorm.jackson.json
import org.ktorm.schema.Table
import org.ktorm.schema.int
import org.ktorm.schema.varchar

@Suppress("unused")
object Projects: Table<Project>("simple_project") {

    val id = int("id").primaryKey().bindTo { it.id }
    val name = varchar("name").bindTo { it.name }
    val description = varchar("description").bindTo { it.description }
    val gitUrl = varchar("git_url").bindTo { it.gitUrl }
    val branch = varchar("branch").bindTo { it.branch }
    val buildCommand = json<List<Command>>("build_command").bindTo { it.buildCommand }
    val environment = json<List<Environment>>("environment").bindTo{ it.environment }
}

// SQL:
// CREATE TABLE simple_project (
//     id INT PRIMARY KEY AUTO_INCREMENT,
//     name VARCHAR(255) NOT NULL,
//     description VARCHAR(255) NOT NULL,
//     git_url VARCHAR(255) NOT NULL,
//     branch VARCHAR(255) NOT NULL,
//     build_command JSON NOT NULL,
//     environment JSON NOT NULL
// );